<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-09-03 20:09:20
 * @LastEditors: voanit
 * @LastEditTime: 2022-09-03 20:12:57
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    var arr = [{ id: 1, name: 'jack' }, { id: 2, name: 'rose' }]
    var obj = { id: 3, name: 'tom' }
    /* for in 可以遍历数组和对象 */
    // for (var k in arr) {
    //   console.log(arr[k]);
    // }
    // for (var k in obj) {
    //   console.log(obj[k]);
    // }

    /* for of 可以遍历数组不可以遍历对象 */
    // for (var k of arr) {
    //   console.log(k);
    // }
    for (var k of obj) {
      console.log(k);
    }
  </script>
</body>

</html>